export const db = uniCloud.databaseForJQL();

export const command = db.command;

db.on(
	'error',
	({
		code, // 错误码详见https://uniapp.dcloud.net.cn/uniCloud/jql.html#returnvalue
		message,
	}) => {
		const { message: messageInstance } = useFeedback(['message']);

		const errorMessage = {
			TOKEN_INVALID_TOKEN_EXPIRED: '登录已过期，请重新登录',
		};

		messageInstance.error(errorMessage[code as keyof typeof errorMessage] || message, {
			keepAliveOnHover: true,
		});
	}
);
